function initCkeditor(editorId, ctxRoot) {
    ctxRoot = ctxRoot ? ctxRoot : '';
    CKEDITOR.dtd.$removeEmpty['i'] = false;
    var ckeditConfig = ckeditorConfig(ctxRoot);
    ckeditConfig.fillEmptyBlocks = false;
    ckeditConfig.enterMode = CKEDITOR.ENTER_BR;
    ckeditConfig.shiftEnterMode = CKEDITOR.ENTER_BR
    var editor = CKEDITOR.replace( editorId, ckeditConfig);
    // editor.config.protectedSource.push(/<protected>[\s\S]*<\/protected>/g);
    // editor.config.protectedSource.push( /\n/g );

    // editor.config.startupMode = 'source';
    editor.config.contentsCss = [ctxRoot + '/webjars/bootstrap/4.3.1/css/bootstrap.min.css',
        ctxRoot + '/resource/frame/font-awesome-4.7.0/css/font-awesome.css',
        ctxRoot + '/resource/common/css/main.css'];
    return editor;
}

function ckeditorConfig(ctxRoot) {
    return {
        plugins: 'image2,sourcearea,toolbar,undo,wysiwygarea,list,liststyle,format,link,basicstyles,pastefromword,filebrowser,table,tabletools,tableselection,' + // autogrow
        'clipboard,textindent,textindent,find,font,detail,api,maximize,colorbutton,templates,preview,justify,font,tableresize,colordialog,' +
        'lineheight,grid,imageresizerowandcolumn',
            extraPlugins: 'imageresize',
            removePlugins: 'image',
            allowedContent: true,
            extraAllowedContent: 'div(*);span(*);i(*);p(*);h1(*);h2(*);h3(*);h4(*)',
            filebrowserBrowseUrl: ctxRoot + '/ckeditor/link.html',
            filebrowserImageBrowseUrl: ctxRoot + '/ckeditor/image.html',
            filebrowserUploadUrl: ctxRoot + '/common/upload',
            toolbar: [
                { name: 'document', items: [ 'Undo', 'Redo', "Copy", 'Find','Maximize' ] },
                { name: 'basicstyles', items: [ 'Bold', 'Italic', 'Strike', 'Underline','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock', '-', 'RemoveFormat'] },
                {name: 'font', items:['Font','FontSize','TextColor', 'BGColor', 'lineheight']},
                { name: 'paragraph', items: [ 'NumberedList', 'BulletedList' ] },
                { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
                // { name: 'insert', items: [ 'EasyImageUpload', 'Table' ] },
                { name: 'insert', items: [ 'Image', 'Table','Grid','AddLayout' ] },
                { name: 'styles', items: [ 'Format', 'Textindent', 'textindent' , 'Outdent', 'Detail'] },
                { name: 'other', items: ['Templates', 'Preview', 'Source']}
            ],
            language : 'zh-cn',
            height: '500px', width: '100%',
            font_names: '宋体/SimSun;新宋体/NSimSun;仿宋_GB2312/FangSong_GB2312;楷体_GB2312/KaiTi_GB2312;黑体/SimHei;微软雅黑/Microsoft YaHei;'
    }
}